package com.gis.servlet.notice;

import com.gis.bean.Notice;
import com.gis.dao.NoticeDao;
import com.gis.util.ResponseUtil;
import com.gis.util.RestResponse;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author t-zhaoheng
 * @since 2022/5/11
 */
@WebServlet("/notice/all")
public class AllNoticeServlet extends HttpServlet {
  NoticeDao noticeDao = NoticeDao.getInstance();

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    this.doPost(req, resp);
  }

  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    List<Notice> noticeList = noticeDao.listAllNotice();
    ResponseUtil.writeJson(resp, RestResponse.success(noticeList));
  }
}
